package org.easy.file.handler;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description: 文件线程
 * @Author: wxl
 * @CreateTime: 2022/12/29 9:23
 */
@Slf4j
public class FileThread implements Runnable{

    private final FileParse fileParse;

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */

    public FileThread (FileParse fileParse) {
        this.fileParse = fileParse;
    }

    @Override
    public void run() {
        // TODO 此处可以做一些过滤，可以将数据存到REDIS,KAFKA上，或者通过SQL直接入库
        log.info("开始执行读取文件内容.....");
        fileParse.fileContents().forEach(log::info);
    }

    public FileParse getFileParse() {
        return fileParse;
    }
}
